package br.ufrj.dcc.tp.servidor.gui.event;

import javax.swing.JTextArea;

public class MessageEvent implements Runnable {
	
	private JTextArea text;
	private String message;
	private EventType e;
	
	public enum EventType {
		CLEAR, APPEND;
	}
	
	public MessageEvent(JTextArea text, EventType e) {
		this.text = text;
		this.e = e;
	}
	
	public MessageEvent(JTextArea text, String message, EventType e) {
		this(text, e);
		this.message = message;
	}

	@Override
	public void run() {
		if( e == EventType.CLEAR) {
			text.setText(null);
		} else if( e == EventType.APPEND ) {
			text.append(message);
		}
	}
}
